/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.sys.web;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.thinkgem.jeesite.common.beanvalidator.BeanValidators;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.utils.DateUtils;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.utils.excel.ExportExcel;
import com.thinkgem.jeesite.common.utils.excel.ImportExcel;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.sys.entity.*;
import com.thinkgem.jeesite.modules.sys.service.*;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


/**
 * 添加物业费Controller
 */
@Controller
@RequestMapping(value = "${adminPath}/sys/userTenement")
public class AddTenementInfoController extends BaseController {

	@Autowired
	private AddTenementInfoService addTenementInfoService;

	@RequestMapping(value="form")
	public String form(TbUserTenementInfo tbUserTenementInfo,Model model){
		if(tbUserTenementInfo.getId()!=null){
			tbUserTenementInfo=addTenementInfoService.getById(tbUserTenementInfo);
		}
		List<TbCommunity> clist=addTenementInfoService.findCommityList();
		model.addAttribute("clist",clist);
		model.addAttribute("tbUserTenementInfo",tbUserTenementInfo);
		return "modules/sys/userTenementForm";
	}

	@RequestMapping(value="saveTenement")
	public String saveTenement(TbUserTenementInfo tbUserTenementInfo,Model model){
	   addTenementInfoService.saveTenementInfo(tbUserTenementInfo);
		return "redirect:" + adminPath + "/sys/user/listTenement?repage";
	}

}
